package com.tengju.user.application.csa;

import com.tengju.user.application.csa.dto.GenSecCustomerServiceForm;
import com.tengju.user.domain.model.csa.GenSecCustomerServiceInfoRepository;
import com.tengju.user.domain.model.user.UserIdCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class GenSecCustomerServiceService {

    private final GenSecCustomerServiceInfoRepository clubCustomerServiceInfoRepository;

    @Autowired
    public GenSecCustomerServiceService(GenSecCustomerServiceInfoRepository clubCustomerServiceInfoRepository) {
        this.clubCustomerServiceInfoRepository = clubCustomerServiceInfoRepository;
    }

    public int updateCustomerServiceInfo(GenSecCustomerServiceForm genSecCustomerServiceForm) {
        return clubCustomerServiceInfoRepository.updateCustomerServiceInfo(
                new UserIdCode(genSecCustomerServiceForm.getSecIdCode()),
                genSecCustomerServiceForm.getCsaName(), genSecCustomerServiceForm.getCsaWeChat(),
                genSecCustomerServiceForm.getHeadImage(), genSecCustomerServiceForm.getWorkDateType(),
                genSecCustomerServiceForm.getStartWorkTime(), genSecCustomerServiceForm.getEndWorkTime(),
                genSecCustomerServiceForm.getCustomerServiceGreetJson());
    }

    public long addCustomerServiceInfo(GenSecCustomerServiceForm genSecCustomerServiceForm) {
        return clubCustomerServiceInfoRepository.addCustomerServiceInfo(
                new UserIdCode(genSecCustomerServiceForm.getSecIdCode()),
                genSecCustomerServiceForm.getCsaName(), genSecCustomerServiceForm.getCsaWeChat(),
                genSecCustomerServiceForm.getHeadImage(), genSecCustomerServiceForm.getWorkDateType(),
                genSecCustomerServiceForm.getStartWorkTime(), genSecCustomerServiceForm.getEndWorkTime(),
                genSecCustomerServiceForm.getCustomerServiceGreetJson());
    }

    public void clearCustomerServiceInfo(Long secIdCode) {
        clubCustomerServiceInfoRepository.clearCustomerServiceInfo(
                new UserIdCode(secIdCode));
    }
}
